package com.ruijie.acl;


import com.ruijie.emp.device.DeviceInterface;
import com.ruijie.foundation.bo.EntityObject;

/**
 * <p>
 * Title: ACL组对象
 * </p>
 * <p>
 * Description: 用于数据库中的ACL组管理
 * </p>
 * <p>
 * Copyright: Copyright (c) 2008
 * </p>
 * <p>
 * Company: Ruijie Co., Ltd.
 * </p>
 * <p>
 * Create Time: 2009-09-14
 * </p>
 * <p>
 * Update Time:
 * </p>
 * <p>
 * Updater:
 * </p>
 * <p>
 * Update Comments:
 * </p>
 *@author ASAI
 */
public class AclPlanInterface extends EntityObject {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 8770132075303413688L;

	private AclDevice aclDevice;
	private AccessGroup outAccessGroup;
	private DeviceInterface deviceInterface;
	private AccessGroup inAccessGroup;
	
	public AclPlanInterface() {
	}

	public AccessGroup getOutAccessGroup() {
		return outAccessGroup;
	}

	public void setOutAccessGroup(AccessGroup outAccessGroup) {
		this.outAccessGroup = outAccessGroup;
	}

	public DeviceInterface getDeviceInterface() {
		return deviceInterface;
	}

	public void setDeviceInterface(DeviceInterface deviceInterface) {
		this.deviceInterface = deviceInterface;
	}

	public AccessGroup getInAccessGroup() {
		return inAccessGroup;
	}

	public void setInAccessGroup(AccessGroup inAccessGroup) {
		this.inAccessGroup = inAccessGroup;
	}

	public AclDevice getAclDevice() {
		return aclDevice;
	}

	public void setAclDevice(AclDevice aclDevice) {
		this.aclDevice = aclDevice;
	}

	public boolean isDisplayOut(){
		boolean result = false;
		if (outAccessGroup != null && inAccessGroup != null){
			if (outAccessGroup.getId().longValue() == inAccessGroup.getId().longValue()){
				result = false;
			}else{
				result = true;
			}
		}
		return result;
	}
	
	/**
	 * 取得字符串
	 * @param inFlag 是否为In
	 * @return
	 */
	public String toString(boolean inFlag) {
		String resultString = "";
		if (deviceInterface != null){
			resultString += deviceInterface.getName() + "(" + deviceInterface.getIfDescr()+")";
		}
		if (outAccessGroup != null && inAccessGroup != null){
			if (outAccessGroup.getId().longValue() == inAccessGroup.getId().longValue()){
				resultString += " [In,Out]   " + outAccessGroup.getName();
			}else if (inFlag){
				resultString += " [In ]   " + inAccessGroup.getName();
			}else{
				resultString += " [Out]   " + outAccessGroup.getName();
			}
		}else if (outAccessGroup != null){
			resultString += " [Out]   " + outAccessGroup.getName() ;
		}else if (inAccessGroup != null){
			resultString += " [In]   " + inAccessGroup.getName();
		}
		
		return resultString;
	}
	
	/**
	 * 取得字符串
	 * @param inFlag 是否为In
	 * @return
	 */
	public String toValueString() {
		String resultString = "";
		if (deviceInterface != null){
			resultString += deviceInterface.getId() + ",";
		}
				
		if (this.inAccessGroup != null && this.outAccessGroup != null) {
			resultString += "InOut," + inAccessGroup.getId() + ";";
		}else if (inAccessGroup != null) {
			resultString += "In," + inAccessGroup.getId() + ";";
		}else if (outAccessGroup != null) {
			resultString += "Out," +outAccessGroup.getId() + ";";
		}
		
		return resultString;
	}
	
}
